Repository navigation
feat(libkernel): implement POSIX mprotect - #1094
Merged
Merged
Conversation
mprotect changes the protection of guest memory through the same path as sceKernelMprotect and reports failures through errno: EINVAL for a null or overflowing range or a range the allocation tracker rejects, ENOMEM when allocation fails. A zero length succeeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both return -1/EINVAL: FreeBSD kern_mprotect (sys/vm/vm_mmap.c) maps only PROTECTION_FAILURE, RESOURCE_SHORTAGE and OUT_OF_BOUNDS to their own errno, so KERN_INVALID_ADDRESS falls to EINVAL. Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
|
Checked build + full ctest on current main with this PR (419/419); Added one commit on top (tests only): Merging once CI is green. |
adriadam10
force-pushed
the
feat/libkernel-mprotect
branch
from
October 8, 2026 06:43
05fcc90 to
53a31b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the POSIX
mprotectexport next tommapandmunmapinPosixMemory.cpp. It callsDoMprotect, the same path assceKernelMprotect(which rounds the range out to guest pages, updates the allocation tracker and the host protection), and follows the POSIX error convention of its neighbours:-1with errno.EINVALDoMprotectrejects (it throws):EINVAL;std::bad_alloc:ENOMEMThe protection value is passed through unchanged, as
sceKernelMprotectdoes.guest_memorygains checks: zero length succeeds, a null address isEINVAL, an unaligned one-byte range makes its page read-only (the tracker reports it readable and not writable, and it can still be read), and protection can be restored to read-write.Title
PPSA17221 (Minecraft) needs #716 to load the modules in its app root, so every run below is current
main+ #716 + the PRs of this set (#1088, #1090–#1096), plus local changes outside it: dialog, NpAuth and TextToSpeech2 stubs that open PRs cover (#560, #925, #301) and a GPU end-of-pipe change that is not submitted. With all of them the title loads a world. The line below is from a run with only this PR left out, Windows 11, WinLibs GCC, normal user session.Without it startup stops at load:
YQOfxL4QfeUismprotect, imported by the title'slibcohtml.Prospero.prx.Tested
Debian 13 (WSL2), GCC 14.2.0, Release: full
ctest390/390 passed (GPU tests skipped: no Vulkan device in WSL), includingguest_memory.Windows 11, WinLibs GCC: PPSA17221 with this PR and the rest of the set loads a world (runs described above). Not tested with Windows
ctest.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code